package com.uncp.comisiondeadmision.comprobantedepago.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import com.uncp.comisiondeadmision.comprobantedepago.beans.ComboBean;
import com.uncp.comisiondeadmision.util.MySqlDBConn;



public class MySqlCombosDAO implements CombosDAO {

	@Override
	public ArrayList<ComboBean> listaData(String sql) throws SQLException {
		Connection conn = null;
		PreparedStatement pst = null;
		ResultSet rs = null;
		ArrayList<ComboBean> lista = new ArrayList<ComboBean>();
		ComboBean bean = null;
		System.out.println("SENTENCIA SQL : " + sql);	
		
		try {
			conn = new MySqlDBConn().getConnection();
			Statement pstm = conn.createStatement();
			ResultSet rst = pstm.executeQuery(sql);
			while (rst.next()) {
				bean = new ComboBean();
				bean.setStrValue(rst.getString(1));
				bean.setStrDescripcion(rst.getString(2));
				lista.add(bean);
			}
			rst.close();
			pstm.close();
		}catch (SQLException e) {
			e.printStackTrace();
		}finally {
			if (rs != null)	 rs.close();
			if (pst != null) pst.close();
			if (conn != null)conn.close();
		}

		return lista;
    }
	}
	
	
	
	
	


